package grafico;



import java.awt.Color;
import java.awt.Font;
import java.awt.SystemColor;

import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JSpinner;

import com.toedter.calendar.JCalendar;
import com.toedter.calendar.JYearChooser;
import com.toedter.calendar.JMonthChooser;
import com.toedter.calendar.JDateChooser;
import com.toedter.components.JSpinField;

public class AltaPasajero_11 extends JPanel {

	/**
	 * Create the panel.
	 */
	private JTextField textNombres;
	private JLabel lblsubTitulo;
	private JLabel lblNombres;
	private JLabel lblAltaPasajero;
	private JLabel icono;
	private JTextField textApellido;
	private JTextField textNroDoc;
	private JLabel lblCuit;
	private JLabel lblFechaDeNacimiento;
	private JLabel lblCalle;
	private JLabel lblIva;
	private JLabel lblLocalidad;
	private JLabel lblPas;
	private JLabel lblTelfono;
	private JLabel lblEmail;
	private JLabel lblOcupacin;
	private JLabel lblNacionalidad;
	private JLabel lblDepatamento;
	private JLabel lblPiso;
	private JLabel lblProvinciaestado;
	private JLabel lblCdigoPostal;
	private JLabel lblN;
	private JTextField textCalle;
	private JTextField textLocalidad;
	private JTextField textCuit_1;
	private JTextField textCuit_2;
	private JLabel label_2;
	private JLabel label_3;
	private JTextField textCuit_3;
	private JTextField textNacionalidad;
	private JTextField textTel;
	private JTextField textEmail;
	private JTextField textOcupacion;
	private JTextField textNacio;
	private JTextField textDto;
	private JTextField textCalleNro;
	private JTextField textPiso;
	private JTextField textProvincia;
	private JTextField textCodigoPostal;

	public AltaPasajero_11(final PantallaPrincipal frame) {
		ImageIcon img=new ImageIcon(this.getClass().getResource("/imagenes/icono.jpg"));
		
		setBackground(new Color(105, 105, 105));
		setForeground(new Color(128, 128, 0));
		
		
		icono = new JLabel(img);
		icono.setBounds(677, 11, 142, 141);
		
		lblAltaPasajero = new JLabel("Alta Pasajero");
		lblAltaPasajero.setBounds(70, 55, 286, 37);
		lblAltaPasajero.setForeground(Color.WHITE);
		lblAltaPasajero.setBackground(Color.WHITE);
		lblAltaPasajero.setFont(new Font("Tahoma", Font.BOLD, 30));
		
		lblsubTitulo = new JLabel("Ingrese los datos del pasajero:");
		lblsubTitulo.setBounds(70, 162, 274, 21);
		lblsubTitulo.setForeground(new Color(250, 128, 114));
		lblsubTitulo.setFont(new Font("Tahoma", Font.BOLD, 17));
		
		lblNombres = new JLabel("Nombres:");
		lblNombres.setBounds(70, 207, 70, 20);
		lblNombres.setForeground(new Color(192, 192, 192));
		lblNombres.setFont(new Font("Tahoma", Font.PLAIN, 16));
		
		textNombres = new JTextField();
		textNombres.setBounds(153, 207, 218, 20);
	


	
	JLabel lblApellido = new JLabel("Apellido:");
	lblApellido.setBounds(402, 207, 70, 20);
	lblApellido.setForeground(Color.LIGHT_GRAY);
	lblApellido.setFont(new Font("Tahoma", Font.PLAIN, 16));
	
	textApellido = new JTextField();
	textApellido.setBounds(546, 207, 218, 20);

	
	JLabel lblTipoDeDocumento = new JLabel("Tipo de documento:\r\n");
	lblTipoDeDocumento.setBounds(70, 259, 152, 20);
	lblTipoDeDocumento.setForeground(Color.LIGHT_GRAY);
	lblTipoDeDocumento.setFont(new Font("Tahoma", Font.PLAIN, 16));
	setLayout(null);
	add(lblAltaPasajero);
	add(lblNombres);
	add(textNombres);
	add(lblApellido);
	add(lblsubTitulo);
	add(textApellido);
	add(icono);
	add(lblTipoDeDocumento);
	
	JComboBox comboBox_TipoDoc = new JComboBox();
	comboBox_TipoDoc.setModel(new DefaultComboBoxModel(new String[] {"DNI", "CI", "LE", "LC"}));
	comboBox_TipoDoc.setBounds(225, 261, 64, 20);
	add(comboBox_TipoDoc);
	
	JLabel lblNDeDocumento = new JLabel("N\u00B0\r\n de documento:\r\n");
	lblNDeDocumento.setForeground(Color.LIGHT_GRAY);
	lblNDeDocumento.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblNDeDocumento.setBounds(402, 259, 152, 20);
	add(lblNDeDocumento);
	
	textNroDoc = new JTextField();
	textNroDoc.setBounds(546, 259, 218, 20);
	add(textNroDoc);
	
	JButton btnBuscar = new JButton("Siguiente");
	btnBuscar.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			darAlta();
		}
	});
	btnBuscar.setBackground(SystemColor.scrollbar);
	btnBuscar.setFont(new Font("Tahoma", Font.PLAIN, 16));
	btnBuscar.setForeground(new Color(70, 130, 180));
	btnBuscar.setBounds(687, 607, 109, 23);
	add(btnBuscar);
	
	JButton btnVolver = new JButton("Volver\r\n");
	btnVolver.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			menu(frame);
		}
	});
	
	
	btnVolver.setBackground(SystemColor.scrollbar);
	btnVolver.setForeground(new Color(70, 130, 180));
	btnVolver.setFont(new Font("Tahoma", Font.PLAIN, 16));
	btnVolver.setBounds(687, 641, 109, 23);
	add(btnVolver);
	
	lblCuit = new JLabel("CUIT:");
	lblCuit.setForeground(Color.LIGHT_GRAY);
	lblCuit.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblCuit.setBounds(70, 290, 51, 20);
	add(lblCuit);
	
	lblFechaDeNacimiento = new JLabel("Fecha de nacimiento:");
	lblFechaDeNacimiento.setForeground(Color.LIGHT_GRAY);
	lblFechaDeNacimiento.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblFechaDeNacimiento.setBounds(70, 321, 152, 20);
	add(lblFechaDeNacimiento);
	
	lblCalle = new JLabel("Calle:");
	lblCalle.setForeground(Color.LIGHT_GRAY);
	lblCalle.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblCalle.setBounds(70, 387, 51, 20);
	add(lblCalle);
	
	lblIva = new JLabel("IVA");
	lblIva.setForeground(Color.LIGHT_GRAY);
	lblIva.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblIva.setBounds(70, 354, 35, 20);
	add(lblIva);
	
	lblLocalidad = new JLabel("Localidad:");
	lblLocalidad.setForeground(Color.LIGHT_GRAY);
	lblLocalidad.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblLocalidad.setBounds(70, 418, 78, 20);
	add(lblLocalidad);
	
	lblPas = new JLabel("Pais:");
	lblPas.setForeground(Color.LIGHT_GRAY);
	lblPas.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblPas.setBounds(70, 453, 70, 20);
	add(lblPas);
	
	lblTelfono = new JLabel("Tel\u00E9fono:");
	lblTelfono.setForeground(Color.LIGHT_GRAY);
	lblTelfono.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblTelfono.setBounds(70, 484, 70, 20);
	add(lblTelfono);
	
	lblEmail = new JLabel("Email:");
	lblEmail.setForeground(Color.LIGHT_GRAY);
	lblEmail.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblEmail.setBounds(70, 515, 70, 20);
	add(lblEmail);
	
	lblOcupacin = new JLabel("Ocupaci\u00F3n:");
	lblOcupacin.setForeground(Color.LIGHT_GRAY);
	lblOcupacin.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblOcupacin.setBounds(70, 546, 102, 20);
	add(lblOcupacin);
	
	lblNacionalidad = new JLabel("Nacionalidad:");
	lblNacionalidad.setForeground(Color.LIGHT_GRAY);
	lblNacionalidad.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblNacionalidad.setBounds(70, 577, 109, 20);
	add(lblNacionalidad);
	
	lblDepatamento = new JLabel("Depatamento:");
	lblDepatamento.setForeground(Color.LIGHT_GRAY);
	lblDepatamento.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblDepatamento.setBounds(518, 383, 109, 20);
	add(lblDepatamento);
	
	lblPiso = new JLabel("Piso:");
	lblPiso.setForeground(Color.LIGHT_GRAY);
	lblPiso.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblPiso.setBounds(735, 381, 70, 20);
	add(lblPiso);
	
	lblProvinciaestado = new JLabel("Provincia/Estado:");
	lblProvinciaestado.setForeground(Color.LIGHT_GRAY);
	lblProvinciaestado.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblProvinciaestado.setBounds(423, 418, 131, 20);
	add(lblProvinciaestado);
	
	lblCdigoPostal = new JLabel("C\u00F3digo Postal:");
	lblCdigoPostal.setForeground(Color.LIGHT_GRAY);
	lblCdigoPostal.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblCdigoPostal.setBounds(417, 534, 109, 20);
	add(lblCdigoPostal);
	
	lblN = new JLabel("N\u00B0:");
	lblN.setForeground(Color.LIGHT_GRAY);
	lblN.setFont(new Font("Tahoma", Font.PLAIN, 16));
	lblN.setBounds(425, 385, 35, 20);
	add(lblN);
	
	textCalle = new JTextField();
	textCalle.setBounds(182, 387, 218, 20);
	add(textCalle);
	
	textLocalidad = new JTextField();
	textLocalidad.setBounds(182, 418, 218, 20);
	add(textLocalidad);
	
	textCuit_1 = new JTextField();
	textCuit_1.addKeyListener(new KeyListener(){
		 
		public void keyTyped(KeyEvent e)
		 
		{if (textCuit_1.getText().length()== 2)
		 
		     e.consume();
		}
		 
		public void keyPressed(KeyEvent arg0) {
		}
		 
		public void keyReleased(KeyEvent arg0) {
		}
		});
	textCuit_1.setBounds(123, 290, 25, 20);
	add(textCuit_1);
	
	textCuit_2 = new JTextField();
	textCuit_2.addKeyListener(new KeyListener(){
		 
		public void keyTyped(KeyEvent e)
		 
		{if (textCuit_2.getText().length()== 8)
		 
		     e.consume();
		}
		 
		public void keyPressed(KeyEvent arg0) {
		}
		 
		public void keyReleased(KeyEvent arg0) {
		}
		});
	textCuit_2.setBounds(168, 290, 120, 20);
	add(textCuit_2);
	
	label_2 = new JLabel("-");
	label_2.setForeground(Color.LIGHT_GRAY);
	label_2.setFont(new Font("Tahoma", Font.BOLD, 18));
	label_2.setBounds(153, 290, 19, 20);
	add(label_2);
	
	label_3 = new JLabel("-");
	label_3.setForeground(Color.LIGHT_GRAY);
	label_3.setFont(new Font("Tahoma", Font.BOLD, 18));
	label_3.setBounds(295, 289, 19, 20);
	add(label_3);
	
	textCuit_3 = new JTextField();
	textCuit_3.setBounds(308, 290, 25, 20);
	textCuit_3.addKeyListener(new KeyListener(){
		 
		public void keyTyped(KeyEvent e)
		 
		{if (textCuit_3.getText().length()== 1)
		 
		     e.consume();
		}
		 
		public void keyPressed(KeyEvent arg0) {
		}
		 
		public void keyReleased(KeyEvent arg0) {
		}
		});
	add(textCuit_3);
	
	textNacionalidad = new JTextField();
	textNacionalidad.setBounds(182, 451, 218, 20);
	add(textNacionalidad);
	
	textTel = new JTextField();
	textTel.setBounds(182, 482, 218, 20);
	add(textTel);
	
	textEmail = new JTextField();
	textEmail.setBounds(182, 514, 218, 20);
	add(textEmail);
	
	textOcupacion = new JTextField();
	textOcupacion.setBounds(182, 548, 218, 20);
	add(textOcupacion);
	
	textNacio = new JTextField();
	textNacio.setBounds(182, 579, 218, 20);
	add(textNacio);
	
	JYearChooser yearChooser = new JYearChooser();
	yearChooser.setBounds(381, 321, 47, 20);
	add(yearChooser);
	
	JMonthChooser monthChooser = new JMonthChooser();
	monthChooser.setBounds(272, 321, 99, 20);
	add(monthChooser);
	
	JSpinField spinField = new JSpinField();
	spinField.setValue(1);
	spinField.setMinimum(1);
	spinField.setMaximum(31);
	spinField.setBounds(228, 321, 29, 20);
	add(spinField);
	
	JComboBox comboBox = new JComboBox();
	comboBox.setModel(new DefaultComboBoxModel(new String[] {"CF", "RI", "E", "CF"}));
	comboBox.setBounds(133, 352, 56, 20);
	add(comboBox);
	
	textDto = new JTextField();
	textDto.setBounds(621, 383, 104, 20);
	add(textDto);
	textDto.setColumns(10);
	
	textCalleNro = new JTextField();
	textCalleNro.setColumns(10);
	textCalleNro.setBounds(452, 383, 56, 20);
	add(textCalleNro);
	
	textPiso = new JTextField();
	textPiso.setColumns(10);
	textPiso.setBounds(774, 381, 56, 20);
	add(textPiso);
	
	textProvincia = new JTextField();
	textProvincia.setBounds(564, 418, 218, 20);
	add(textProvincia);
	
	textCodigoPostal = new JTextField();
	textCodigoPostal.setColumns(10);
	textCodigoPostal.setBounds(523, 536, 104, 20);
	add(textCodigoPostal);
}
	
private void menu(PantallaPrincipal frame) {
	this.setVisible(false);
	frame.setContentPane(new Menu(frame));
	
}
private void darAlta(){
	try{
	
	if (textApellido.getText() == null || textNombres.getText()== null || textNroDoc.getText() == null || 
			textCuit_1.getText() == null || textCuit_2.getText() == null|| textCuit_3.getText() == null || 
			textCalle.getText() == null || textCalleNro.getText() ==null || textNacionalidad.getText() == null || 
			textProvincia.getText() == null || textLocalidad.getText() == null ||textCodigoPostal.getText() == null ||
			textOcupacion.getText() == null || textTel.getText() == null){
		throw new ExceptionNull();
	}
	}
	catch(ExceptionNull e1){ JOptionPane.showMessageDialog(this,"No se han cargado todos los datos", "Error", JOptionPane.INFORMATION_MESSAGE);}
}
}
